package com.mnc.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
@Entity
public class User implements Serializable{


	/**
	 * 
	 */
	private static final long serialVersionUID = -3631455621878072222L;
	//主键id
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int userId;
	//登录名
	@Column
	private String userLoginName;
	//登录密码
	@Column
	private String userLoginPass;
	//用户昵称
	@Column
	private String userNickName;
	//用户头像
	@Column
	private String userHead;
	//性别
	@Column
	private char userSex;
	//邮箱
	@Column
	private String userEmail;
	//籍贯
	@Column
	private String userFrom;
	//学校
	@Column
	private String userSchool;
	//通知
	@OneToMany(mappedBy="reciver",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	@MapKey(name="noticeDate DESC")
	private Set<Notice> myNotices = new HashSet<Notice>();
	//建立的团
	@OneToMany(mappedBy="creater",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<UserUnit> myUnits = new HashSet<UserUnit>();
	//加入的团
	@ManyToMany(mappedBy="members",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<UserUnit> myJoinUnits = new HashSet<UserUnit>();
	//收藏
	@OneToMany(mappedBy="owner",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	@MapKey(name="collectDate DESC")
	private Set<UserCollect> myCollects = new HashSet<UserCollect>();
	//类型
	@ManyToOne(cascade=CascadeType.REFRESH,fetch=FetchType.EAGER)
	private UserType myType;
	//发表的评论
	@OneToMany(mappedBy="byUser",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<ArticleComment> myComments=new HashSet<ArticleComment>();
	//文章
	@OneToMany(mappedBy="writer",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<Article> myArticles=new HashSet<Article>();
	//留言
	@OneToMany(mappedBy="byUser",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<PageNote> myNotes=new HashSet<PageNote>();
	//空间
	@OneToOne(cascade= {CascadeType.PERSIST,CascadeType.REFRESH},fetch=FetchType.LAZY)
	private UserPage myPage;
	//团讨论
	@OneToMany(mappedBy="talker",cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	private Set<UnitTalk> myTalks=new HashSet<UnitTalk>(); 
	
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public String getUserLoginName() {
		return userLoginName;
	}
	public void setUserLoginName(String userLoginName) {
		this.userLoginName = userLoginName;
	}
	public String getUserLoginPass() {
		return userLoginPass;
	}
	public void setUserLoginPass(String userLoginPass) {
		this.userLoginPass = userLoginPass;
	}
	public char getUserSex() {
		return userSex;
	}
	public void setUserSex(char userSex) {
		this.userSex = userSex;
	}
	public String getUserNickName() {
		return userNickName;
	}
	public void setUserNickName(String userNickName) {
		this.userNickName = userNickName;
	}
	public String getUserHead() {
		return userHead;
	}
	public void setUserHead(String userHead) {
		this.userHead = userHead;
	}
	public String getUserEmail() {
		return userEmail;
	}
	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}
	public String getUserFrom() {
		return userFrom;
	}
	public void setUserFrom(String userFrom) {
		this.userFrom = userFrom;
	}
	public String getUserSchool() {
		return userSchool;
	}
	public void setUserSchool(String userSchool) {
		this.userSchool = userSchool;
	}
	public Set<Notice> getMyNotices() {
		return myNotices;
	}
	public void setMyNotices(Set<Notice> myNotices) {
		this.myNotices = myNotices;
	}
	public Set<UserUnit> getMyUnits() {
		return myUnits;
	}
	public void setMyUnits(Set<UserUnit> myUnits) {
		this.myUnits = myUnits;
	}
	public Set<UserUnit> getMyJoinUnits() {
		return myJoinUnits;
	}
	public void setMyJoinUnits(Set<UserUnit> myJoinUnits) {
		this.myJoinUnits = myJoinUnits;
	}
	public Set<UserCollect> getMyCollects() {
		return myCollects;
	}
	public void setMyCollects(Set<UserCollect> myCollects) {
		this.myCollects = myCollects;
	}
	public UserType getMyType() {
		return myType;
	}
	public void setMyType(UserType myType) {
		this.myType = myType;
	}
	public Set<ArticleComment> getMyComments() {
		return myComments;
	}
	public void setMyComments(Set<ArticleComment> myComments) {
		this.myComments = myComments;
	}
	public Set<Article> getMyArticles() {
		return myArticles;
	}
	public void setMyArticles(Set<Article> myArticles) {
		this.myArticles = myArticles;
	}
	public Set<PageNote> getMyNotes() {
		return myNotes;
	}
	public void setMyNotes(Set<PageNote> myNotes) {
		this.myNotes = myNotes;
	}
	public UserPage getMyPage() {
		return myPage;
	}
	public void setMyPage(UserPage myPage) {
		this.myPage = myPage;
	}
	public Set<UnitTalk> getMyTalks() {
		return myTalks;
	}
	public void setMyTalks(Set<UnitTalk> myTalks) {
		this.myTalks = myTalks;
	}
	
	
}
